﻿using Basic.FlowModel.DB;
using Basic.FlowRemoteModel;
using WeDonekRpc.Helper;
using WeDonekRpc.SqlSugar;

namespace Basic.FlowDAL.lmpl
{
    internal class FlowAuditNodeStateDAL : BasicDAL<DBFlowAuditNodeState, long>, IFlowAuditNodeStateDAL
    {
        public FlowAuditNodeStateDAL ( IRepository<DBFlowAuditNodeState> basicDAL ) : base(basicDAL, "audit.node.state")
        {
        }

        public void SetJumpNode ( long logId, long[] nodeId )
        {
            if ( !this._BasicDAL.Update(a => a.Status == FlowNodeAuditStatus.已跳过, a => a.LogId == logId && nodeId.Contains(a.NodeId) && a.Status == FlowNodeAuditStatus.待开始) )
            {
                throw new ErrorException("flow.audit.node.state.set.fail");
            }
        }
    }
}
